package com.example.hdwx.myapplication.base_activity;

import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.hdwx.myapplication.HomeActivity.HomeActivity;
import com.example.hdwx.myapplication.R;

public class WelcomeActivity extends AppCompatActivity {
    LinearLayout line;
    ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        line= (LinearLayout) findViewById(R.id.welcome_activity);
        imageView= (ImageView) findViewById(R.id.img_welcome_activity);
        init();
    }

    private void init() {
        //  开始动画效果
        /*imageView.setImageResource(R.drawable.animation_list2);
        AnimationDrawable animationDrawable= (AnimationDrawable) imageView.getDrawable();
        animationDrawable.start();*/
        Animation animation=new AlphaAnimation(0f,1f);
        animation.setDuration(4000);
        line.setAnimation(animation);
        line.startAnimation(animation);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //跳转到home_activity
                Intent intent=new Intent(WelcomeActivity.this, HomeActivity.class);
                startActivity(intent);
                //关闭该页面
                finish();
            }
        },2000);

    }
}
